gtkoverlay: Fix issues with remove
authorAlexander Larsson <alexl@redhat.com>
Mon, 15 Jun 2015 14:32:50 +0000 (16:32 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 15 Jun 2015 14:32:50 +0000 (16:32 +0200)
The iteration now progresses past a delete, so make sure we iterate
safely. Also, don't chain up if we removed a child.

gtk/gtkoverlay.c

index f5962a10bc9e29eb77831193fb133a0f0e1cb159..eb6ac04177fb2d3f332f60cf59df3b236a88df39 100644 (file)
@@ -497,13 +497,14 @@ gtk_overlay_remove (GtkContainer *container,
 {
   GtkOverlayPrivate *priv = GTK_OVERLAY (container)->priv;
   GtkOverlayChild *child;
-  GSList *children;
+  GSList *children, *next;
   gboolean removed;
 
   removed = FALSE;
-  for (children = priv->children; children; children = children->next)
+  for (children = priv->children; children; children = next)
     {
       child = children->data;
+      next = children->next;
 
       if (child->widget == widget)
         {
@@ -524,7 +525,8 @@ gtk_overlay_remove (GtkContainer *container,
         gtk_widget_child_notify (child->widget, "index");
     }
 
-  GTK_CONTAINER_CLASS (gtk_overlay_parent_class)->remove (container, widget);
+  if (!removed)
+    GTK_CONTAINER_CLASS (gtk_overlay_parent_class)->remove (container, widget);
 }
 
 /**